package com.mcptt.config.body.location;

import java.io.StringReader;
import java.io.UnsupportedEncodingException;

import org.xmlpull.v1.XmlPullParser;

import android.util.Xml;

public class LocationInfoBody {

  private static final String End_Mcptt_Tag = "</location-info>";
  public static final int Type_Request = 1;
  public static final int Type_Distribute = 2;
  public static final int Type_Configuration = 3;
  public static final int Type_Err = -1;



  public static final String PTT_ACTION       ="PTT_ACTION";


//  public static int parseMsgType(String bodyStr) 
//  {
//    
//    int index = bodyStr.indexOf(End_Mcptt_Tag);
//    bodyStr= bodyStr.substring(0, index + End_Mcptt_Tag.length());
//    bodyStr = bodyStr.trim();
//  
//    int returnCode = Type_Err;
//
//    XmlPullParser parser = Xml.newPullParser();
//
//    String funname;
//
//    try {
//      parser.setInput(new StringReader(bodyStr));
//      int eventType = parser.getEventType();
//
//      while (eventType != XmlPullParser.END_DOCUMENT) {
//
//        funname = parser.getName();
//        if (funname != null) {
//          // 及时消息处理
//          if (funname.equals("Request")) 
//          {
//            returnCode = Type_Request;
//            break;
//          } 
//          else if (funname.equals("Report")) 
//          {
//            returnCode = Type_Report;
//            break;
//          }
//          else if (funname.equals("Configuration")) {
//            returnCode = Type_Configuration;
//            break;
//          }
//        }
//
//        eventType = parser.next();
//      }
//
//    } catch (Exception e) {
//      e.printStackTrace();
//      returnCode = Type_Err;
//    }
//    return returnCode;
//  }
	public LocationInfoBody()
	{
	}
	
	public String toString()
	{
		StringBuffer strBuff = new StringBuffer();
		strBuff.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
		strBuff.append("<location-info xmlns=\"urn:3gpp:ns:mcpttLocationInfo:1.0\">");
		strBuff.append("<Report ReportID=\"xxx\" ReportType=\"Emergency\">");
		strBuff.append("<TriggerId>xxx</TriggerId>");
		
		strBuff.append("<CurrentLocation>");
		strBuff.append("<CurrentCoordinate>");
		
		strBuff.append("<longitude type=\"Normal\">");
		strBuff.append("<three-bytes>16777215</three-bytes>");
		strBuff.append("</longitude>");
		
		strBuff.append("<latitude type=\"Normal\">");
		strBuff.append("<three-bytes>16777215</three-bytes>");
		strBuff.append("</latitude>");
		
		strBuff.append("</CurrentCoordinate>");
		strBuff.append("</CurrentLocation>");
		strBuff.append("</Report>");
		
		strBuff.append("</location-info>");
		
		try {
			return new String(strBuff.toString().getBytes(),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return strBuff.toString();
	}
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
